#include "RoundScene.h"
#include "config.h"

RoundScene::RoundScene()
{
    confirm = new QPushButton(this);
    // 初始化确认按钮
    confirm->setFixedSize(200, 100);
    confirm->setStyleSheet("QPushButton{image: url(:/res/confirm.png)}");
    // 像素画下载
    QString path[] = {CYCLE_PATH, RECT_PATH, LEFT_CYCLE_PATH, RIGHT_CYCLE_PATH};
    for (int i = 0; i < 4; ++i)
    {
        img[i].load(path[i]);
    }
    // 初始化关卡
    level = 1;
}

void RoundScene::paintEvent(QPaintEvent *e)
{
    QString levelName[] = {"第一关", "第二关", "第三关", "第四关"};
    QString levelValue[] = {"*20", "*30", "*40", "*50"};
    QPainter painter(this);

    if (level > 0 && level <= 4)
    {
        painter.setFont(QFont("楷体", 55, QFont::Bold));
        painter.drawText(WidgetInfo::WIDGET_WIDTH / 2 - 110, WidgetInfo::WIDGET_HEIGHT / 2 - 150, QString(levelName[level - 1]));
        painter.drawPixmap(WidgetInfo::WIDGET_WIDTH / 2 - 50, WidgetInfo::WIDGET_HEIGHT / 2 - 100, 100, 100, img[level - 1]);
        painter.setFont(QFont("楷体", 45, QFont::Bold));
        painter.drawText(WidgetInfo::WIDGET_WIDTH / 2 - 50, WidgetInfo::WIDGET_HEIGHT / 2 + 100, QString(levelValue[level - 1]));
    }

    confirm->move(WidgetInfo::WIDGET_WIDTH / 2 - 100, WidgetInfo::WIDGET_HEIGHT / 2 + 150);
    confirm->show();
}
